package com.training.collections.listex;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.training.collections.vo.Employee;

public class ArrayListEx {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Employee employee0 = new Employee("Naresh", "10");
		Employee employee1 = new Employee("Alex", "11");
		Employee employee2 = new Employee("Kalyan", "12");
		Employee employee3 = new Employee("Varshith", "13");

		List employeeList = new ArrayList();
		employeeList.add(employee0);
		employeeList.add(employee1);
		employeeList.add(employee2);
		employeeList.add(employee3);

		for (Iterator iterator = employeeList.iterator(); iterator.hasNext();) {
			Employee employee = (Employee) iterator.next();
			employee.display();
		}

		System.out.println("---- NEW Employee Joins Here ");
		Employee employee4 = new Employee("Srikanth", "14");
		employeeList.add(employee4);

		System.out.println("Afer New Employee joins");

		for (Iterator iterator = employeeList.iterator(); iterator.hasNext();) {
			Employee employee = (Employee) iterator.next();
			employee.display();
		}

		System.out.println("----Employee remove Here ");

		employeeList.remove(employee2);
		
		System.out.println("Afer Employee Removes from List");

		for (Iterator iterator = employeeList.iterator(); iterator.hasNext();) {
			Employee employee = (Employee) iterator.next();
			employee.display();
		}

	}

}
